package hms.generic;

import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

/**
 * This splash panel is only used to display the Splash screen when the system
 * is first started and waiting for the user to log-in.
 * 
 * @author Matthew Johnson
 *
 */
public class SplashPanel extends JPanel{
	
	// Default serial version UID
	private static final long serialVersionUID = 1L;
	
	// Splash screen image to display
	private BufferedImage image;
	
	/**
	 * Constructor to get the image from the file.
	 */
	public SplashPanel(){
		try {
			
			// TODO: FIX THIS CLASSPATH!
			image = ImageIO.read(new File("C:\\Users\\ohmatt\\Dropbox\\eclipse\\HMSProject\\images\\splash.png"));
		} catch (IOException e) {
			
			// Print error to console
			// TODO: Replace with error handler if used
			e.printStackTrace();
			
		}
	}
	
	/**
	 * Override the paint component method to draw the splash screen image to the full size of the screen.
	 */
	@Override
	public void paintComponent(Graphics g){
		
		// Draw the image
		g.drawImage(image, 0, 0, Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height
				-JMenuBar.HEIGHT, null);
		
	}
}
